package com.tengju.user.domain.model.club;

import com.tengju.user.domain.shared.DomainException;
import com.tengju.user.domain.shared.DomainExceptionCode;
import lombok.Value;
import lombok.experimental.NonFinal;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

@Value
public class Zone {

    private ZoneId zoneId;

    @NonFinal
    private String name;

    @NonFinal
    private String headImg;

    private String createBy;

    @NonFinal
    private String updateBy;

    private LocalDateTime updateTime;

    public void editZoneInfo(String newName,String newHeadImg,String updateBy) {
        if (StringUtils.isNotEmpty(newName)) {
            this.name = newName;
        }
        if (StringUtils.isNotEmpty(newHeadImg)) {
            this.headImg = newHeadImg;
        }
        if (StringUtils.isEmpty(updateBy)) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA,"操作人名字为空");
        }
        this.updateBy = updateBy;
    }

}
